import java.util.*;

public class TreeTest {
    static public Scanner sc = new Scanner(System.in);

    static public void main(String [] args) {
        Tree tree = new Tree(new TreeDataCmp() {
            public int cmp(Object d1, Object d2) {
                return (int)d1 - (int)d2;
            }
        });

        int num;

        while (true) {
            System.out.printf("请输入数字(-1为退出): ");
            num = sc.nextInt();

            if (num == -1)
                break;

            tree.add(num);
        }

        tree.travel(0, "层次遍历: ");
        tree.travel(1, "前序遍历: ");
        tree.travel(2, "中序遍历: ");
        tree.travel(3, "后序遍历: ");
    }
}
